# coding:utf-8

import ctypes
import logging
import os
import time
from PIL import Image

# 时间格式化
timeFt = '%Y-%m-%d %H:%M:%S'


def pilImage():
    '''
    扫描图片
    :return:
    '''
    print 'No.1 time %s' % time.strftime(timeFt, time.localtime(time.time()))
    im = Image.open('./seer.png')  # type: Image.Image
    w, h = im.size
    pix = im.load()

    # 遍历图片的rgb
    for x in range(w):
        for y in range(h):
            r = pix[x, y][0]
            g = pix[x, y][1]
            b = pix[x, y][2]
            print x, y, '%x%x%x' % (r, g, b)


def cmd():
    '''
    cmd命令相关
    :return:
    '''
    str = os.popen("adb shell")


def logging():
    '''
    日志相关
    :return:
    '''
    # 获取桌面路径
    desktop = os.path.join(os.path.expanduser("~"), 'Desktop')

    # 日志测试
    logging.basicConfig(
        filename=desktop + '/yinyangshi_yuhun.log',
        filemode='a',  # r只读，w可写，a追加
        level=logging.DEBUG,
        format='%(asctime)s  %(filename)s : %(levelname)s  %(message)s',
        datefmt='%Y-%m-%d %A %H:%M:%S'
    )

    # 日志配置
    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)

    formatter = logging.Formatter('%(asctime)s  %(filename)s : %(levelname)s  %(message)s')
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(formatter)
    logger.addHandler(ch)

    # 日志打印，同时输出到文件
    logger.info("日志配置测试")


def timeDiff():
    '''
    计算时间差
    :return:
    '''
    now = time.time()
    future = time.localtime(1515121248 + 600)
    print time.strftime(timeFt, time.localtime(1515121248))
    print time.strftime(timeFt, future)


def winTip():
    '''
    win下弹窗提示
    :return:
    '''
    ctypes.windll.user32.MessageBoxA(0, u"点击确定 开始处理data目录下面的xls文件,分析处理完成后会有提示.^_ ^".encode('gb2312'),
                                     u' 信息'.encode('gb2312'), 0)


if __name__ == '__main__':
    winTip()
